<HTML><HEAD>
<!--
    --------------
    Frames Grabber
    --------------
-->

<SCRIPT LANGUAGE="JavaScript"><!-- hide from old browsers

/*
    THE JAVASCRIPT COOKBOOK by Erica Sadun, webrx@mindspring.com
    Copyright (c)2000 by Charles River Media.  All Rights Reserved.
    
    This applet can only be re-used or modifed by license holders of the
    JavaScript Cookbook CD-ROM.  Credit must be given in the source
    code and this copyright notice must be maintained. If you do
    not hold a license to the JavaScript Cookbook, you may NOT
    duplicate or modify this code for your own use.

    Use at your own risk. No warranty is given or implied of the suitability 
    of this applet for any specific application. Neither Erica Sadun nor 
    Charles River Media will be held responsible for any unwanted effects 
    due to the use of this applet or any derivative. 
*/

function recurseFrames(aFrame, level)
{
    // report the name
    for (var i = 0; i < level; i++) document.write("  ")
    if (aFrame.name == "")
        document.writeln("<b>&lt;unnamed frame&gt;</b>")
    else
        document.writeln("<b>"+aFrame.name+"</b>")
    
    // recurse the children
    for (var i = 0; i < aFrame.frames.length; i++)
        recurseFrames(aFrame.frames[i], level+1)
}

<!-- done hiding --></SCRIPT></HEAD>

<BODY bgcolor="ffffff" link="0000ff" vlink="770077">
    
<FONT COLOR="007777"><H1><IMG SRC="../GRAFX/SPICE.JPG" WIDTH=37 HEIGHT=72
ALIGN = LEFT>Frame Grabber</H1></FONT>
<BLOCKQUOTE><FONT SIZE=4>
    This script traverses the frame tree from the 
    <FONT COLOR="770000">_Top</FONT> on down and
    reports the contents of this window.
</FONT></BLOCKQUOTE>

<SCRIPT>
    document.write('<BLOCKQUOTE><PRE>')
    recurseFrames(top, 0)
    document.write('</PRE></BLOCKQUOTE>')
</SCRIPT>

<br><br>
<FONT COLOR="007777"><H2>Discussion</H2></FONT>
<FONT SIZE=4>
    Preformatted text provides proper
    indentation as the script traverses the frame tree.
    The parameter <FONT COLOR="770000">level</FONT>
    stores the degree of recursion--and, hence, the
    current level of indentation.
</FONT>

<FONT COLOR="770000"><PRE>
function recurseFrames(aFrame, level)
{
    // report the name
    for (var i = 0; i &lt; level; i++) document.write("  ")
    if (aFrame.name == "")
        document.writeln("&lt;b&gt;&amp;lt;unnamed frame&amp;gt;&lt;/b&gt;")
    else
        document.writeln("&lt;b&gt;"+aFrame.name+"&lt;/b&gt;")
    
    // recurse for children
    for (var i = 0; i < aFrame.frames.length; i++)
        recurseFrames(aFrame.frames[i], level+1)
}
</PRE></FONT>

<h5>Copyright &copy;1996 by Charles River Media, All Rights Reserved</h5>
</BODY>
</HTML>